package com.zzl.rabbitmq.deadletter;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.zzl.rabbitmq.utils.RabbitMqUtils;

import java.nio.charset.StandardCharsets;

/**
 * Title: DeadLetteProducer.class<br>
 * Description: <br>
 * Copyright (c)  2021    <br>
 * Create DateTime: 2021/7/15 14:54 <br>
 *
 * @author zhuangzhuangliang
 */
public class DeadLetterProducer {

    public static final String NORMAL_EXCHANGE ="normal_exchange";
    public static final String NORMAL_QUEUE ="normal_queue";

    public static void main(String[] args) throws Exception{

        Channel channel = RabbitMqUtils.getChannel();

        AMQP.BasicProperties basicProperties = new AMQP.BasicProperties().builder().expiration("10000").build();
        for (int i = 1; i < 11; i++) {
            String message = "info: "+i;
            channel.basicPublish(NORMAL_EXCHANGE,"zhangsan",basicProperties,message.getBytes(StandardCharsets.UTF_8));
        }
    }
}
